package com.dwfyc.utils;

import javax.faces.context.FacesContext;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

public class Accesos_Contextos {

	public static HttpSession getSesion() {
		HttpSession salida = (HttpSession) FacesContext.getCurrentInstance()
				.getExternalContext().getSession(false);
		return salida;
	}

	public static HttpServletRequest getPeticion() {
		HttpServletRequest peticion = (HttpServletRequest) FacesContext
				.getCurrentInstance().getExternalContext().getRequest();
		return peticion;
	}

	public static ServletContext getAplicacion() {
		ServletContext aplicacion = ((HttpSession) FacesContext
				.getCurrentInstance().getExternalContext().getSession(false))
				.getServletContext();
		return aplicacion;
	}

	public static HttpServletResponse getRespuesta() {

		HttpServletResponse respuesta = (HttpServletResponse) FacesContext
				.getCurrentInstance().getExternalContext().getResponse();
		return respuesta;
	}

	public static ApplicationContext getApplication_Context() {
		ApplicationContext application = WebApplicationContextUtils
				.getWebApplicationContext(Accesos_Contextos.getAplicacion());
		return application;
	}

}
